blob: 3c9bf45829e084a2309117b44520ad4275e9d4d7 [file] [log] [blame]
Junio C Hamano1d3a6c72007-01-09 11:13:471git-remote(1)
2============
3
4NAME
5----
Junio C Hamano5b3533d2014-02-27 23:07:156git-remote - Manage set of tracked repositories
Junio C Hamano1d3a6c72007-01-09 11:13:477
8
9SYNOPSIS
10--------
11[verse]
Junio C Hamanofce7c7e2008-07-02 03:06:3812'git remote' [-v | --verbose]
Junio C Hamano3d1b5a12013-05-17 23:34:0213'git remote add' [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>
Junio C Hamano28363492008-11-14 08:26:3114'git remote rename' <old> <new>
Junio C Hamano693e7092012-09-12 22:56:5315'git remote remove' <name>
Junio C Hamano369e3402013-10-15 18:40:2516'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)
Junio C Hamanoe0238c22012-02-23 22:45:5017'git remote set-branches' [--add] <name> <branch>...
Junio C Hamano1eb56092015-10-05 20:39:5318'git remote get-url' [--push] [--all] <name>
Junio C Hamano57827fb2010-01-23 03:02:5019'git remote set-url' [--push] <name> <newurl> [<oldurl>]
20'git remote set-url --add' [--push] <name> <newurl>
21'git remote set-url --delete' [--push] <name> <url>
Junio C Hamano5a6d5f72013-05-01 23:37:0322'git remote' [-v | --verbose] 'show' [-n] <name>...
23'git remote prune' [-n | --dry-run] <name>...
Junio C Hamanod2179ef2010-10-22 04:12:1724'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...]
Junio C Hamano1d3a6c72007-01-09 11:13:4725
26DESCRIPTION
27-----------
28
29Manage the set of repositories ("remotes") whose branches you track.
30
Junio C Hamano1d3a6c72007-01-09 11:13:4731
Junio C Hamanoeb415992008-06-08 22:49:4732OPTIONS
33-------
34
35-v::
36--verbose::
37Be a little more verbose and show remote url after name.
Junio C Hamanobf984de2009-11-23 06:11:1938NOTE: This must be placed between `remote` and `subcommand`.
Junio C Hamanoeb415992008-06-08 22:49:4739
40
Junio C Hamanoee1e4282007-02-04 08:32:0441COMMANDS
42--------
43
44With no arguments, shows a list of existing remotes. Several
45subcommands are available to perform operations on the remotes.
46
47'add'::
48
49Adds a remote named <name> for the repository at
Junio C Hamano1d3a6c72007-01-09 11:13:4750<url>. The command `git fetch <name>` can then be used to create and
51update remote-tracking branches <name>/<branch>.
Junio C Hamano17dde0e2007-02-26 09:50:2152+
53With `-f` option, `git fetch <name>` is run immediately after
54the remote information is set up.
55+
Junio C Hamanocc7636a2010-05-21 14:57:5356With `--tags` option, `git fetch <name>` imports every tag from the
57remote repository.
58+
59With `--no-tags` option, `git fetch <name>` does not import tags from
60the remote repository.
61+
Junio C Hamano6bf68cf2015-03-06 23:46:2962By default, only tags on fetched branches are imported
63(see linkgit:git-fetch[1]).
64+
Junio C Hamano17dde0e2007-02-26 09:50:2165With `-t <branch>` option, instead of the default glob
66refspec for the remote to track all branches under
Junio C Hamano360e3a12011-07-13 23:51:5667the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>`
Junio C Hamano17dde0e2007-02-26 09:50:2168is created. You can give more than one `-t <branch>` to track
Junio C Hamano67fad6d2007-05-06 08:53:1269multiple branches without grabbing all branches.
Junio C Hamano17dde0e2007-02-26 09:50:2170+
Junio C Hamano360e3a12011-07-13 23:51:5671With `-m <master>` option, a symbolic-ref `refs/remotes/<name>/HEAD` is set
Junio C Hamanod257cff2009-03-18 05:27:1672up to point at remote's `<master>` branch. See also the set-head command.
Junio C Hamano58155b42007-09-15 07:46:1473+
Junio C Hamanob76a6862012-05-02 22:02:4674When a fetch mirror is created with `--mirror=fetch`, the refs will not
Junio C Hamanoee3adc32011-04-06 19:53:3875be stored in the 'refs/remotes/' namespace, but rather everything in
76'refs/' on the remote will be directly mirrored into 'refs/' in the
77local repository. This option only makes sense in bare repositories,
78because a fetch would overwrite any local commits.
79+
Junio C Hamanob76a6862012-05-02 22:02:4680When a push mirror is created with `--mirror=push`, then `git push`
81will always behave as if `--mirror` was passed.
Junio C Hamano1d3a6c72007-01-09 11:13:4782
Junio C Hamano28363492008-11-14 08:26:3183'rename'::
84
Junio C Hamano97bcb482010-11-25 03:16:0785Rename the remote named <old> to <new>. All remote-tracking branches and
Junio C Hamano28363492008-11-14 08:26:3186configuration settings for the remote are updated.
87+
88In case <old> and <new> are the same, and <old> is a file under
89`$GIT_DIR/remotes` or `$GIT_DIR/branches`, the remote is converted to
90the configuration file format.
91
Junio C Hamano693e7092012-09-12 22:56:5392'remove'::
Junio C Hamano4fd58d42007-09-30 00:51:1493'rm'::
94
Junio C Hamano97bcb482010-11-25 03:16:0795Remove the remote named <name>. All remote-tracking branches and
Junio C Hamano4fd58d42007-09-30 00:51:1496configuration settings for the remote are removed.
97
Junio C Hamanod257cff2009-03-18 05:27:1698'set-head'::
99
Junio C Hamano360e3a12011-07-13 23:51:56100Sets or deletes the default branch (i.e. the target of the
101symbolic-ref `refs/remotes/<name>/HEAD`) for
Junio C Hamanod257cff2009-03-18 05:27:16102the named remote. Having a default branch for a remote is not required,
103but allows the name of the remote to be specified in lieu of a specific
104branch. For example, if the default branch for `origin` is set to
105`master`, then `origin` may be specified wherever you would normally
106specify `origin/master`.
107+
Junio C Hamano369e3402013-10-15 18:40:25108With `-d` or `--delete`, the symbolic ref `refs/remotes/<name>/HEAD` is deleted.
Junio C Hamanod257cff2009-03-18 05:27:16109+
Junio C Hamano369e3402013-10-15 18:40:25110With `-a` or `--auto`, the remote is queried to determine its `HEAD`, then the
Junio C Hamano360e3a12011-07-13 23:51:56111symbolic-ref `refs/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote
Junio C Hamanod257cff2009-03-18 05:27:16112`HEAD` is pointed at `next`, "`git remote set-head origin -a`" will set
Junio C Hamano360e3a12011-07-13 23:51:56113the symbolic-ref `refs/remotes/origin/HEAD` to `refs/remotes/origin/next`. This will
Junio C Hamanod257cff2009-03-18 05:27:16114only work if `refs/remotes/origin/next` already exists; if not it must be
115fetched first.
116+
Junio C Hamano360e3a12011-07-13 23:51:56117Use `<branch>` to set the symbolic-ref `refs/remotes/<name>/HEAD` explicitly. e.g., "git
118remote set-head origin master" will set the symbolic-ref `refs/remotes/origin/HEAD` to
Junio C Hamanod257cff2009-03-18 05:27:16119`refs/remotes/origin/master`. This will only work if
120`refs/remotes/origin/master` already exists; if not it must be fetched first.
121+
122
Junio C Hamanof5de4cf2010-06-19 00:33:17123'set-branches'::
124
125Changes the list of branches tracked by the named remote.
126This can be used to track a subset of the available remote branches
127after the initial setup for a remote.
128+
129The named branches will be interpreted as if specified with the
130`-t` option on the 'git remote add' command line.
131+
132With `--add`, instead of replacing the list of currently tracked
133branches, adds to that list.
134
Junio C Hamano1eb56092015-10-05 20:39:53135'get-url'::
136
137Retrieves the URLs for a remote. Configurations for `insteadOf` and
138`pushInsteadOf` are expanded here. By default, only the first URL is listed.
139+
140With '--push', push URLs are queried rather than fetch URLs.
141+
142With '--all', all URLs for the remote will be listed.
143
Junio C Hamano57827fb2010-01-23 03:02:50144'set-url'::
145
Junio C Hamanoc3550302015-02-18 22:34:11146Changes URLs for the remote. Sets first URL for remote <name> that matches
Junio C Hamano57827fb2010-01-23 03:02:50147regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If
Junio C Hamanoc3550302015-02-18 22:34:11148<oldurl> doesn't match any URL, an error occurs and nothing is changed.
Junio C Hamano57827fb2010-01-23 03:02:50149+
150With '--push', push URLs are manipulated instead of fetch URLs.
151+
Junio C Hamanoc3550302015-02-18 22:34:11152With '--add', instead of changing existing URLs, new URL is added.
Junio C Hamano57827fb2010-01-23 03:02:50153+
Junio C Hamanoc3550302015-02-18 22:34:11154With '--delete', instead of changing existing URLs, all URLs matching
155regex <url> are deleted for remote <name>. Trying to delete all
156non-push URLs is an error.
157+
158Note that the push URL and the fetch URL, even though they can
159be set differently, must still refer to the same place. What you
160pushed to the push URL should be what you would see if you
161immediately fetched from the fetch URL. If you are trying to
162fetch from one place (e.g. your upstream) and push to another (e.g.
163your publishing repository), use two separate remotes.
164
Junio C Hamano57827fb2010-01-23 03:02:50165
Junio C Hamanoee1e4282007-02-04 08:32:04166'show'::
Junio C Hamano1d3a6c72007-01-09 11:13:47167
Junio C Hamanoee1e4282007-02-04 08:32:04168Gives some information about the remote <name>.
Junio C Hamano401939f2007-07-01 06:34:30169+
170With `-n` option, the remote heads are not queried first with
171`git ls-remote <name>`; cached information is used instead.
Junio C Hamanoee1e4282007-02-04 08:32:04172
173'prune'::
174
Junio C Hamano97bcb482010-11-25 03:16:07175Deletes all stale remote-tracking branches under <name>.
Junio C Hamano39381a72007-02-02 07:35:15176These stale branches have already been removed from the remote repository
Junio C Hamano0bbd4672007-02-20 04:52:14177referenced by <name>, but are still locally available in
178"remotes/<name>".
Junio C Hamano401939f2007-07-01 06:34:30179+
Junio C Hamano9f883862009-08-11 06:23:52180With `--dry-run` option, report what branches will be pruned, but do not
Junio C Hamano6fb124c2008-06-13 10:04:01181actually prune them.
Junio C Hamano0bbd4672007-02-20 04:52:14182
183'update'::
184
Junio C Hamano118d2772007-02-21 20:24:10185Fetch updates for a named set of remotes in the repository as defined by
186remotes.<group>. If a named group is not specified on the command line,
Junio C Hamano9f883862009-08-11 06:23:52187the configuration parameter remotes.default will be used; if
Junio C Hamano361c1332007-11-14 12:17:22188remotes.default is not defined, all remotes which do not have the
Junio C Hamano118d2772007-02-21 20:24:10189configuration parameter remote.<name>.skipDefaultUpdate set to true will
Junio C Hamano35738e82008-01-07 07:55:46190be updated. (See linkgit:git-config[1]).
Junio C Hamano98e32c32009-04-13 02:39:53191+
192With `--prune` option, prune all the remotes that are updated.
Junio C Hamano39381a72007-02-02 07:35:15193
Junio C Hamanoee1e4282007-02-04 08:32:04194
195DISCUSSION
196----------
197
Junio C Hamano1d3a6c72007-01-09 11:13:47198The remote configuration is achieved using the `remote.origin.url` and
199`remote.origin.fetch` configuration variables. (See
Junio C Hamano35738e82008-01-07 07:55:46200linkgit:git-config[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:47201
202Examples
203--------
204
Junio C Hamano6ac2f142007-03-01 01:24:56205* Add a new remote, fetch, and check out a branch from it
206+
Junio C Hamano1d3a6c72007-01-09 11:13:47207------------
208$ git remote
209origin
210$ git branch -r
Junio C Hamanoa1952302013-07-01 21:31:18211 origin/HEAD -> origin/master
212 origin/master
213$ git remote add staging git://git.kernel.org/.../gregkh/staging.git
Junio C Hamano1d3a6c72007-01-09 11:13:47214$ git remote
Junio C Hamano1d3a6c72007-01-09 11:13:47215origin
Junio C Hamanoa1952302013-07-01 21:31:18216staging
217$ git fetch staging
218...
219From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
220 * [new branch] master -> staging/master
221 * [new branch] staging-linus -> staging/staging-linus
222 * [new branch] staging-next -> staging/staging-next
Junio C Hamano1d3a6c72007-01-09 11:13:47223$ git branch -r
Junio C Hamanoa1952302013-07-01 21:31:18224 origin/HEAD -> origin/master
225 origin/master
226 staging/master
227 staging/staging-linus
228 staging/staging-next
229$ git checkout -b staging staging/master
Junio C Hamano1d3a6c72007-01-09 11:13:47230...
231------------
232
Junio C Hamano1aa40d22010-01-21 17:46:43233* Imitate 'git clone' but track only selected branches
Junio C Hamano6ac2f142007-03-01 01:24:56234+
235------------
236$ mkdir project.git
237$ cd project.git
238$ git init
239$ git remote add -f -t master -m master origin git://example.com/git.git/
240$ git merge origin
241------------
242
243
Junio C Hamano9049d912008-05-29 02:09:50244SEE ALSO
Junio C Hamano1d3a6c72007-01-09 11:13:47245--------
Junio C Hamano35738e82008-01-07 07:55:46246linkgit:git-fetch[1]
247linkgit:git-branch[1]
248linkgit:git-config[1]
Junio C Hamano1d3a6c72007-01-09 11:13:47249
Junio C Hamano1d3a6c72007-01-09 11:13:47250GIT
251---
Junio C Hamanof7c042d2008-06-06 22:50:53252Part of the linkgit:git[1] suite